{include file=member.header.html}
{$images_upload}
{$editor_upload}
{$build_editor}
<script type="text/javascript">
/*上传图片*/
function add_uploadedfile(file_data) {
    if (file_data.instance == 'goods_image') {
        $('#goods_images').append('<li ectype="handle_pic" file_id="' + file_data.file_id + '" thumbnail="' + file_data.thumbnail + '"><input type="hidden" value="' + file_data.file_id + '" name="goods_file_id[]"/><div class="pic"><img src="' + file_data.thumbnail + '" width="55" height="55" alt="" /><div ectype="handler" class="bg"><p class="operation"><span class="cut_in" ectype="set_cover" ecm_title="{$lang.set_cover}"></span><span class="delete" ectype="drop_image" ecm_title="{$lang.drop}"></span></p></div></div></li>');
        trigger_uploader();
        if ($('#big_goods_image').attr('src') == '{$goods.default_goods_image}') {
            set_cover(file_data.file_id);
        }
        if (GOODS_SWFU.getStats().files_queued == 0) {
            window.setTimeout(function() {
                $('#uploader').hide();
                $('#open_uploader').find('.show').attr('class', 'hide');
            }, 1000);
        }
    } else if (file_data.instance == 'desc_image') {
        $('#desc_images').append('<li file_name="' + file_data.file_name + '" file_path="' + file_data.file_path + '" ectype="handle_pic" file_id="' + file_data.file_id + '"><input type="hidden" name="desc_file_id[]" value="' + file_data.file_id + '"><div class="pic" style="z-index: 2;"><img src="' + file_data.file_path + '" width="50" height="50" alt="' + file_data.file_name + '" /></div><div ectype="handler" class="bg" style="z-index: 3;display:none"><img src="' + file_data.file_path + '" width="50" height="50" alt="' + file_data.file_name + '" /><p class="operation"><a href="javascript:void(0);" class="cut_in" ectype="insert_editor" ecm_title="{$lang.insert_editor}"></a><span class="delete" ectype="drop_image" ecm_title="{$lang.drop}"></span></p><p class="name">' + file_data.file_name + '</p></div></li>');
        trigger_uploader();
        if (EDITOR_SWFU.getStats().files_queued == 0) {
            window.setTimeout(function() {
                $('#editor_uploader').hide();
            }, 1000);
        }
    }
}
/*设置封面*/
function set_cover(file_id) {
    if (typeof(file_id) == 'undefined') {
        $('#big_goods_image').attr('src', '{$goods.default_goods_image}');
        return;
    }
    var obj = $('*[file_id="' + file_id + '"]');
    $('*[file_id="' + file_id + '"]').clone(true).prependTo('#goods_images');
    $('*[ectype="handler"]').hide();
    $('#big_goods_image').attr('src', obj.attr('thumbnail'));
    obj.remove();
}

/*快递-买家承担运费*/
function show_wt() {
  var pid = $('#shipping_ids').val();
  if (pid) {
    $.get('index.php?app=my_goods&act=get_shipping_type&pid=' + pid, function(data) {
      var data = eval('(' + data + ')');
      if (data.compute_mode == 'by_weight') {
        $('#wt').show();
      } else {
        $('#wt').hide();
      }
    });
  } else {
    $('#wt').hide();
  }
}
</script>
<script type="text/javascript" src="{res file=js/goods_commission.js}"></script>
<script type="text/javascript" src="{lib file=my_goods.js}" charset="utf-8"></script>
<script>
$(function() {
  /*快递运费切换*/
  $('#shipping_id').change(function() {
    var pid = $(this).attr('value');
    if (pid == 1) {
      $(this).after('<select name="shipping_id" onchange="show_wt()" id="shipping_ids"><option value="" checked  >请选择模板</option>{foreach from=$shipping key=key item=data}<option value="{$data.shipping_id}" {if $data.shipping_id eq $goods.shipping_id}selected{/if}>{$data.shipping_name}</option>{/foreach}</select>');
    } else {
      var shipping_ids = $('#shipping_ids');
      if (shipping_ids.length > 0) {
        shipping_ids.remove();
      }
    }
    $('#wt').hide();
  });
  
});
</script>

<div class="content f-cb">
  {include file=path.html}
  {include file=member.menu.html}
  <!-- 内容右边栏 -->
  <div class="con-goods-r">
    <ul class="goods-t f-cb">
      <li>
        <a class="current">新增商品</a>
      </li>
    </ul>
    <div class="goods-panes">
      <form action="" method="post" name="goods-create-frm" id="goods_form" autocomplete="off">
        <div class="goods-p-t">
          <table class="goods-p-table">
            <tr>
              <td width="160" align="right"> <i>*</i>
                商品分类：
              </td>
              <td>
                <p class="select" id="gcategory">
                  <select>
                    <option>{$lang.select_pls}</option>
                    {html_options options=$mgcategories}
                  </select>
                  <input type="text" id="cate_id" name="cate_id" value="{$goods.cate_id}" class="mls_id" />
                  <input type="hidden" name="cate_name" value="{$goods.cate_name|escape}" class="mls_names" />
                  <span style="color: #999;margin-left: 20px;">用于网站分类</span>
                </p>
              </td>
            </tr>
            <tr>
              <td align="right"> <i>*</i>
                本店分类：
              </td>
              <td>
                <p class="select">
                  <select name="sgcate_id[]" class="sgcategory">
                    <option value="0">{$lang.select_pls}</option>
                    {html_options options=$sgcategories}
                  </select>
                  <a href="javascript:add_sgcategory();" id="add_sgcategory" class="btn" style="color:#00A0E9">{$lang.add_scategory}</a>
                  <span style="color: #999;margin-left: 20px;">用于本店分类，该商品{$lang.note_for_sgcategory}</span>
                </p>
              </td>
            </tr>
            <tr>
              <td align="right">
                <i>*</i>
                商品名称：
              </td>
              <td>
                <input title="{$goods.goods_name|escape}" type="text" name="goods_name" value="{$goods.goods_name|escape}" class="width_normal" />
                <span class="goods-tips">还能输入50个字</span>
              </td>
            </tr>
            <tr>
              <td align="right">品牌：</td>
              <td>
                <input type="text" name="brand" class="width_normal" />
              </td>
            </tr>
          </table>
        </div>
        <dl id="goods-attr-list" style="display:none;">
          <dt>
            <h4>商品属性</h4>
          </dt>
          <dd id="goods-property"></dd>
        </dl>
        <dl>
          <dt>
            <h4>商品规格及销售信息</h4>
          </dt>
          <dd id="goods-format">
            <table class="goods-p-table" width="100%">
              <tr id="goods-spec-list" style="display: none;">
                <td width="160" align="right" valign="top">
                  <h6>产品规格：</h6>
                </td>
                <td>
                  <div class="goods-f-d" id="goods-format-prod"></div>
                </td>
              </tr>
              <tr id="goods-sale-info">
                <td width="160" align="right" valign="top">
                  <h6>销售信息：</h6>
                </td>
                <td>
                  <div class="goods-f-d" id="goods_info_wrap">
                    <dl class="goods-f-c f-cb">
                      <dt>
                        <i>*</i> <em>报价方式：</em>
                      </dt>
                      <dd>
                        <input type="radio" name="pricetype" value="1" checked="checked" id="goods-pricetype-a" />
                        <label for="goods-pricetype-a">按产品数量报价</label>
                        &nbsp;&nbsp;&nbsp;&nbsp;
                        <span style="display:none" id="pricetype_b_wrap">
                          <input type="radio" name="pricetype" value="2" id="goods-pricetype-b"/>
                          <label for="goods-pricetype-b">按产品规格报价</label>
                        </span>
                      </dd>
                    </dl>
                    <dl class="goods-f-tab f-cb">
                      <dt>
                        <i>*</i> <em>价格区间：</em>
                      </dt>
                      <dd>
                        <table id="goods-price-table" width="100%">
                          <tr>
                            <th width="40" align="right">&nbsp;</th>
                            <th width="80">购买数量</th>
                            <th width="60">&nbsp;</th>
                            <th width="80">商品零售价</th>
                            <th width="60">&nbsp;</th>
                            <th width="80">商品市场价</th>
                            <th>&nbsp;</th>
                            <th width="40">&nbsp;</th>
                          </tr>
                          <tr>
                            <td align="right">起订量</td>
                            <td>
                              <input type="text" name="pricelist_num[]"  id="orderNum" class="{required:true,messages:{required:'不能为空'}}" onkeyup="zNum(this)" />
                            </td>
                            <td>件及以上：</td>
                            <td>
                              <input type="text" name="pricelist_price[]" id="orderPrice" class="{required:true,messages:{required:'不能为空'}}" onblur="creat_market_price(this)" />
                            </td>
                            <td>元/件</td>
                            <td>
                              <input type="text" name="pricelist_market_price[]" class="{required:true,messages:{required:'不能为空'}}" onblur="wl.zWeight(this)" />
                            </td>
                            <td> 元/件</td>
                            <td>&nbsp;</td>
                          </tr>
                          <tr>
                            <td colspan="8">
                              <a class="g-p-btn">增加价格区间</a>
                            </td>
                          </tr>
                        </table>
                      </dd>
                    </dl>
                    <dl class="goods-f-tab f-cb" id="goods-sale-num">
                      <dt>
                        <i>*</i>
                        <em>可售数量：</em>
                      </dt>
                      <dd></dd>
                    </dl>
                    <dl class="goods-f-tab f-cb" id="goods-sale-format">
                      <dt>
                        <i>*</i>
                        <em>可售数量：</em>
                      </dt>
                      <dd></dd>
                    </dl>
                    <dl class="goods-f-c f-cb" id="goods_code">
                      <dt>
                        <i>&nbsp;</i>
                        <em>商品货号：</em>
                      </dt>
                      <dd>
                        <input type="text" name="goods_code" class="width_normal" />
                      </dd>
                    </dl>
                    <dl class="goods-f-c f-cb" id="start_num"></dl>
                    <dl class="goods-f-c f-cb f-dn" id="floor_price">
                      <dt>
                        <i>*</i>
                        <em>商品底价：</em>
                      </dt>
                      <dd>
                        <input type="text" name="floor_price_num" class="width_normal" onblur="wl.zWeight(this)" />
                      </dd>
                    </dl>
                    <dl class="goods-f-c f-cb">
                      <dt>
                        <i id="zl">*</i>
                        <em>可售总量：</em>
                      </dt>
                      <dd>
                        <input type="text" id="goods-tatalNum" value="" style="background:#fff;text-align: center;" name="totalstock" />
                        件
                        <span style="display:none;">可售总量是各规格可售数量的总和</span>
                      </dd>
                    </dl>
                  </div>
                </td>
              </tr>
            </table>
            <table>
              <tr>
                <td align="right" width="160">
                  <i>*</i>
                  计量单位：
                </td>
                <td>
                  <select name="delivery_unit">
                    <option value="" selected>请选择</option>
                    <!--{foreach from=$goods_units item=item}-->
                    <option value="{$item}">{$item}</option>
                    <!--{/foreach}--> </select>
                </td>
              </tr>
            </table>
          </dd>
        </dl>
        <dl>
          <dt>
            <h4>商品图片</h4>
          </dt>
          <dd>
            <div class="add_wrap_img">
              <table width="100%">
                <tr>
                  <td width="340">
                    <div class="pic_list">
                      <div class="big_pic">
                        <img id="big_goods_image" src="{$goods.default_goods_image}" width="300" height="300" alt="" />
                      </div>
                      <div class="small_pic">
                        <ul id="goods_images">
                          <!--{foreach from=$goods_images item=goods_iamge}-->
                          <li ectype="handle_pic" file_id="{$goods_iamge.file_id}" thumbnail="{$goods_iamge.thumbnail}">
                            <input type="hidden" name="goods_file_id[]" value="{$goods_iamge.file_id}">
                            <div class="pic">
                              <img src="{$goods_iamge.thumbnail}" width="55" height="55" />
                              <div ectype="handler" class="bg">
                                <p class="operation">
                                  <span class="cut_in" ectype="set_cover" ecm_title="{$lang.set_cover}"></span>
                                  <span class="delete" ectype="drop_image" ecm_title="{$lang.drop}"></span>
                                </p>
                              </div>
                            </div>
                          </li>
                          <!--{/foreach}--> </ul>
                        <div class="clear"></div>
                      </div>
                    </div>
                  </td>
                  <td class="add_wrap_imgtd" valign="top">
                    <div class="upload_btn">
                      <div class="upload" id="open_uploader"> <b class="hide">{$lang.upload_goods_image}</b>
                      </div>
                      <div class="upload_con" id="uploader" style="display:none">
                        <div class="upload_con_top"></div>
                        <div class="upload_wrap">
                          <ul>
                            <li class="btn1">
                              <div id="divSwfuploadContainer">
                                <div id="divButtonContainer">
                                  <span id="spanButtonPlaceholder"></span>
                                </div>
                              </div>
                            </li>
                            <li>
                              <!--<iframe src="index.php?app=comupload&act=view_iframe&id={$id}&belong={$belong}&instance=goods_image" width="86" height="30" scrolling="no" frameborder="0"></iframe>
                            -->
                          </li>
                          <!-- <li id="open_remote" class="btn2">{$lang.rem_upload}</li> -->
                          <li>请上传本地图片</li>
                        </ul>
                        <div id="remote" class="upload_file" style="display:none">
                          <iframe src="index.php?app=comupload&act=view_remote&id={$id}&belong={$belong}&instance=goods_image" width="272" height="55" scrolling="no" frameborder="0"></iframe>
                        </div>
                        <div id="goods_upload_progress"></div>
                        <div class="upload_txt">
                          <span>{$lang.note_for_upload}</span>
                        </div>
                      </div>
                      <div class="upload_con_bottom"></div>
                    </div>
                  </div>
                  <table width="100%" class="wrap_img_list">
                    <tr>
                      <td colspan="2">提示：</td>
                    </tr>
                    <tr>
                      <td>1，</td>
                      <td>本地上传图片大小不能超过500k。</td>
                    </tr>
                    <tr>
                      <td>2，</td>
                      <td>本类目下您最多可以上传5张图片。</td>
                    </tr>
                    <tr>
                      <td>3，</td>
                      <td>背景图是范列，请尽量参照范例选图。</td>
                    </tr>
                    <tr>
                      <td>4，</td>
                      <td>上传的图片格式需为jpeg,jpg,gif,png。</td>
                    </tr>
                    <tr>
                      <td>5，</td>
                      <td>建议图片的尺寸为400x400。</td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </div>
        </dd>
      </dl>
      <dl>
        <dt>
          <h4>商品说明</h4>
        </dt>
        <dd>
          <div class="add_wrap">
            <div class="editor">
              <div>
                <textarea name="description" id="description"  style="width:100%; height:400px;"></textarea>
              </div>
              <div style=" position: relative; top: 10px; z-index: 5;">
                <a class="btn3" id="open_editor_uploader">{$lang.uploadedfile}</a>
                <div class="upload_con" id="editor_uploader" style="display:none">
                  <div class="upload_con_top"></div>
                  <div class="upload_wrap">
                    <ul>
                      <li>
                        <div id="divSwfuploadContainer">
                          <div id="divButtonContainer">
                            <span id="editor_upload_button"></span>
                          </div>
                        </div>
                      </li>
                      <!--li>
                      <iframe src="index.php?app=comupload&act=view_iframe&id={$id}&belong={$belong}&instance=desc_image" width="86" height="30" scrolling="no" frameborder="0"></iframe>
                    </li-->
                    <li id="open_editor_remote" class="btn2">{$lang.rem_upload}</li>
                  </ul>
                  <div id="editor_remote" class="upload_file" style="display:none">
                    <iframe src="index.php?app=comupload&act=view_remote&id={$id}&belong={$belong}&instance=desc_image" width="272" height="39" scrolling="no" frameborder="0"></iframe>
                  </div>
                  <div id="editor_upload_progress"></div>
                  <div class="upload_txt">
                    <span>{$lang.note_for_upload}</span>
                  </div>
                </div>
                <div class="upload_con_bottom"></div>
              </div>
            </div>
            <ul id="desc_images" class="preview">
              <!--{foreach from=$desc_images item=desc_image}-->
              <li ectype="handle_pic" file_name="{$desc_image.file_name|escape}" file_path="{$desc_image.file_path}" file_id="{$desc_image.file_id}">
                <input type="hidden" name="desc_file_id[]" value="{$desc_image.file_id}">
                <div class="pic">
                  <img src="{$desc_image.file_path}" width="50" height="50" alt="{$desc_image.file_name|escape}" title="{$desc_image.file_name|escape}" />
                </div>
                <div ectype="handler" class="bg">
                  <img src="{$desc_image.file_path}" width="50" height="50" alt="{$desc_image.file_name|escape}" title="{$desc_image.file_name|escape}" />
                  <p class="operation">
                    <a class="cut_in" ectype="insert_editor" href="javascript:void(0);" ecm_title="{$lang.insert_editor}"></a>
                    <span class="delete" ectype="drop_image" ecm_title="{$lang.drop}"></span>
                  </p>
                  <p title="{$desc_image.file_name|escape}" class="name">{$desc_image.file_name|escape}</p>
                </div>
              </li>
              <!--{/foreach}--> </ul>
            <div class="clear"></div>
          </div>
        </div>
      </dd>
    </dl>
    <dl>
      <dt>
        <h4>物流运费信息</h4>
      </dt>
      <dd>
        <table class="goods-p-table">
          <tr>
            <td align="right" width="100">
              <i>*</i>
              发货方式：
            </td>
            <td>
              <input type="radio" name="delivery_type" value="1" id="delivery_type_a" checked />
              <label for="delivery_type_a">快递</label>
              &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              <input type="radio" name="delivery_type" value="2" id="delivery_type_b" />
              <label for="delivery_type_b">物流</label>
            </td>
          </tr>
          <tr>
            <td align="right">
              <i>*</i>
              运费：
            </td>
            <td id="freight_pay_wrap">
              <select id="shipping_id" name="freight_pay">
                <option value="" selected>请选择</option>
                <option value="0">卖家承担运费</option>
                <option value="1">买家承担运费</option>
              </select>
              <select id="logistics_pay">
                <option value="" selected>请选择</option>
                <option value="0">卖家承担运费</option>
                <option value="-1">运费到付</option>
              </select>
            </td>
          </tr>
          <tr>
            <td align="right">
              <i>*</i>
              发货时间：
            </td>
            <td>
              <select name="delivery_time">
                <option value="" selected>请选择</option>
                {html_options options=$shipping_time}
              </select>
            </td>
          </tr>

          <tr>
            <td align="right">
              <i id="wt" style="display:none">*</i>
              商品单位重量：
            </td>
            <td>
              <input type="text" onblur="wl.zWeight(this)" name="gweight" />
              （公斤/个）
            </td>
          </tr>
        </table>
      </dd>
    </dl>
    <dl>
      <dt>
        <h4>特色服务及售后信息</h4>
      </dt>
      <dd>
        <table class="goods-p-table">
          <tr>
            <td align="right">上架时间：</td>
            <td>
              <input type="radio" value="0" name="if_show"  checked="checked"/>
              待上架区
            </td>
          </tr>
        </table>
      </dd>
    </dl>
    <div class="goods-sub">
      <input type="submit" name="" class="b-radius" value="发布商品" />
    </div>
  </form>
</div>
</div>
</div>
<iframe name="iframe_post" id="iframe_post" width="0" height="0"></iframe>
{include file=footer.html}